//
//  ManageController.m
//  NoNameAmazing
//
//  Created by liuyang on 2017/9/11.
//  Copyright © 2017年 北京执行力科技有限公司. All rights reserved.
//

#import "ManageController.h"
#import "StayMangeCell.h"
@interface ManageController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView * tableView;
@property(nonatomic,strong)NSArray * infoArray;
@property(nonatomic,strong)NSDictionary * dict;
@end

@implementation ManageController

- (void)viewDidLoad {
    [super viewDidLoad];
    _infoArray = @[@"校区",@"建筑物号",@"宿舍房间号",@"床位号",@"宿舍电话",@"入住日期",@"迁出日期"];
    [self createTable];
    [self requestManage];
}

-(void)createTable
{
    _tableView=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height-44) style:UITableViewStyleGrouped];
    _tableView.delegate=self;
    _tableView.dataSource=self;
    _tableView.showsVerticalScrollIndicator=NO;
    _tableView.showsHorizontalScrollIndicator=NO;
    _tableView.userInteractionEnabled= YES ;
    
    _tableView.contentInset = UIEdgeInsetsMake(0, 0, -5, 0);
    
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.view addSubview:_tableView];
}

#pragma mark - 数据源
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.infoArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    StayMangeCell *cell = [[[NSBundle mainBundle] loadNibNamed:@"StayMangeCell" owner:nil options:nil] lastObject];
    cell.titleLab.text = self.infoArray[indexPath.row];
    if(indexPath.row==0){
        cell.infoLab.text = _dict[@"XQH"];
    }else if (indexPath.row==1){
        cell.infoLab.text = _dict[@"JZWH"];
    }else if (indexPath.row==2){
        cell.infoLab.text = _dict[@"SSFJH"];
    }else if (indexPath.row==3){
        cell.infoLab.text = _dict[@"CWH"];
    }else if (indexPath.row==4){
        cell.infoLab.text = _dict[@"SSDH"];
    }else if (indexPath.row==5){
        cell.infoLab.text = _dict[@"RZRQ"];
    }else if (indexPath.row==6){
        cell.infoLab.text = _dict[@"QCRQ"];
    }
    return cell;
}
#pragma mark - 代理方法
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 43;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.0001;
}

-(void)requestManage
{
    NSDictionary *params = @{@"userid":[us objectForKey:kUserid]};
    [NetWorkManager requestWithType:1 withUrlString:@"/selectInformation/getStudentRoom.do" withParaments:params withSuccessBlock:^(id object) {
        if ([object[@"message"]isEqualToString:@"成功"]) {
            _dict = [[NSDictionary alloc]initWithDictionary:object[@"studentRoomList"][0]];
            [_tableView reloadData];
        }
        
    } withFailureBlock:^(NSError *error) {
        
        
    } progress:^(float progress) {
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
